package mjc.egg;
import mjc.tds.*;
import mjc.type.*;
import mjc.gc.*;
import mjc.compiler.*;
import java.util.*;
import mg.egg.eggc.compiler.libjava.lex.*;
import mg.egg.eggc.compiler.libjava.*;
import mg.egg.eggc.compiler.libjava.problem.IProblem;
import java.util.Vector;
import java.util.List;
import java.util.ArrayList;
public class S_INST_MJAVA implements IDstNode {
LEX_MJAVA scanner;
  S_INST_MJAVA() {
    }
  S_INST_MJAVA(LEX_MJAVA scanner) {
    this.scanner = scanner;
    offset = 0;
    length = 0;
    this.att_scanner = scanner;
    }
int [] sync= new int[0];
  String att_code;
  int att_dep;
  TDS att_tds;
  TAM att_cpu;
  int att_taille;
  LEX_MJAVA att_scanner;
  LinkedList<TDS> att_tdsi;
  private void regle35() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    T_MJAVA x_2 = new T_MJAVA(scanner ) ;
    T_MJAVA x_3 = new T_MJAVA(scanner ) ;
    S_E_MJAVA x_4 = new S_E_MJAVA(scanner) ;
    T_MJAVA x_6 = new T_MJAVA(scanner ) ;
    S_BLOC_MJAVA x_7 = new S_BLOC_MJAVA(scanner) ;
    //appel
      action_auto_inh_35(x_4, x_7);
    x_2.analyser(LEX_MJAVA.token_tantque);
      addChild(x_2);
    x_3.analyser(LEX_MJAVA.token_paro);
      addChild(x_3);
    x_4.analyser() ;
      addChild(x_4);
      action_type_35(x_4, x_7);
    x_6.analyser(LEX_MJAVA.token_parf);
      addChild(x_6);
    x_7.analyser() ;
      addChild(x_7);
      action_code22_35(x_4, x_7);
      action_taille_35(x_4, x_7);
     length =x_7.getOffset() + x_7.getLength()  -offset;
  }
  private void regle29() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    S_E_MJAVA x_2 = new S_E_MJAVA(scanner) ;
    T_MJAVA x_3 = new T_MJAVA(scanner ) ;
    //appel
      action_auto_inh_29(x_2);
    x_2.analyser() ;
      addChild(x_2);
    x_3.analyser(LEX_MJAVA.token_pv);
      addChild(x_3);
      action_code16_29(x_2);
      action_taille_29(x_2);
     length =x_3.getOffset() + x_3.getLength()  -offset;
  }
  private void regle31() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    T_MJAVA x_2 = new T_MJAVA(scanner ) ;
    T_MJAVA x_3 = new T_MJAVA(scanner ) ;
    S_E_MJAVA x_4 = new S_E_MJAVA(scanner) ;
    T_MJAVA x_6 = new T_MJAVA(scanner ) ;
    S_BLOC_MJAVA x_7 = new S_BLOC_MJAVA(scanner) ;
    S_SIX_MJAVA x_8 = new S_SIX_MJAVA(scanner) ;
    //appel
      action_auto_inh_31(x_4, x_7, x_8);
    x_2.analyser(LEX_MJAVA.token_si);
      addChild(x_2);
    x_3.analyser(LEX_MJAVA.token_paro);
      addChild(x_3);
    x_4.analyser() ;
      addChild(x_4);
      action_type_31(x_4, x_7, x_8);
    x_6.analyser(LEX_MJAVA.token_parf);
      addChild(x_6);
    x_7.analyser() ;
      addChild(x_7);
    x_8.analyser() ;
      addChild(x_8);
      action_code18_31(x_4, x_7, x_8);
      action_taille_31(x_4, x_7, x_8);
     length =x_8.getOffset() + x_8.getLength()  -offset;
  }
  private void regle34() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    T_MJAVA x_2 = new T_MJAVA(scanner ) ;
    S_E_MJAVA x_3 = new S_E_MJAVA(scanner) ;
    T_MJAVA x_4 = new T_MJAVA(scanner ) ;
    //appel
      action_auto_inh_34(x_3);
    x_2.analyser(LEX_MJAVA.token_retour);
      addChild(x_2);
    x_3.analyser() ;
      addChild(x_3);
    x_4.analyser(LEX_MJAVA.token_pv);
      addChild(x_4);
      action_code21_34(x_3);
      action_taille_34(x_3);
      action_type_34(x_3);
     length =x_4.getOffset() + x_4.getLength()  -offset;
  }
  private void regle30() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    S_BLOC_MJAVA x_2 = new S_BLOC_MJAVA(scanner) ;
    //appel
      action_auto_inh_30(x_2);
    x_2.analyser() ;
      addChild(x_2);
      action_code17_30(x_2);
      action_taille_30(x_2);
     length =x_2.getOffset() + x_2.getLength()  -offset;
  }
  private void regle28() throws Exception {
 offset = scanner.getOffset(0);

    //declaration
    S_TYPE_MJAVA x_2 = new S_TYPE_MJAVA(scanner) ;
    T_MJAVA x_3 = new T_MJAVA(scanner ) ;
    S_AFFX_MJAVA x_4 = new S_AFFX_MJAVA(scanner) ;
    T_MJAVA x_5 = new T_MJAVA(scanner ) ;
    //appel
      action_auto_inh_28(x_2, x_3, x_4);
    x_2.analyser() ;
      addChild(x_2);
    x_3.analyser(LEX_MJAVA.token_ident);
      addChild(x_3);
    x_4.analyser() ;
      addChild(x_4);
    x_5.analyser(LEX_MJAVA.token_pv);
      addChild(x_5);
      action_type_28(x_2, x_3, x_4);
      action_code15_28(x_2, x_3, x_4);
      action_taille_28(x_2, x_3, x_4);
     length =x_5.getOffset() + x_5.getLength()  -offset;
  }
private void action_type_35(S_E_MJAVA x_4, S_BLOC_MJAVA x_7) throws Exception {
try {
// instructions
if (!(x_4.att_type.compareTo( new DTYPE("boolean", 1)))){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_T_02, MJAVAMessages.T_02,new Object[]{});

}

}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_31(S_E_MJAVA x_4, S_BLOC_MJAVA x_7, S_SIX_MJAVA x_8) throws Exception {
try {
// instructions
x_4.att_tds=this.att_tds;
x_7.att_tds=this.att_tds;
x_8.att_tds=this.att_tds;
x_4.att_tdsi=this.att_tdsi;
x_7.att_tdsi=this.att_tdsi;
x_8.att_tdsi=this.att_tdsi;
x_7.att_dep=this.att_dep;
x_8.att_dep=this.att_dep;
x_4.att_cpu=this.att_cpu;
x_7.att_cpu=this.att_cpu;
x_8.att_cpu=this.att_cpu;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_taille_31(S_E_MJAVA x_4, S_BLOC_MJAVA x_7, S_SIX_MJAVA x_8) throws Exception {
try {
// instructions
this.att_taille=0;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_29(S_E_MJAVA x_2) throws Exception {
try {
// instructions
x_2.att_tds=this.att_tds;
x_2.att_tdsi=this.att_tdsi;
x_2.att_cpu=this.att_cpu;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_type_31(S_E_MJAVA x_4, S_BLOC_MJAVA x_7, S_SIX_MJAVA x_8) throws Exception {
try {
// instructions
if (!((x_4.att_type.compareTo( new DTYPE("boolean", 1))))){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_T_02, MJAVAMessages.T_02,new Object[]{});

}

}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_taille_35(S_E_MJAVA x_4, S_BLOC_MJAVA x_7) throws Exception {
try {
// instructions
this.att_taille=0;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_34(S_E_MJAVA x_3) throws Exception {
try {
// instructions
x_3.att_tds=this.att_tds;
x_3.att_tdsi=this.att_tdsi;
x_3.att_cpu=this.att_cpu;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_code22_35(S_E_MJAVA x_4, S_BLOC_MJAVA x_7) throws Exception {
try {
// instructions
this.att_code=this.att_cpu.tantQue(x_4.att_code, x_7.att_code);
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_code21_34(S_E_MJAVA x_3) throws Exception {
try {
// instructions
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_TRACE, MJAVAMessages.TRACE,new Object[]{""+"Inst de retour "});

this.att_code="";
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_taille_28(S_TYPE_MJAVA x_2, T_MJAVA x_3, S_AFFX_MJAVA x_4) throws Exception {
try {
// locales
INFO loc_i;
// instructions
this.att_taille=x_2.att_type.getTaille();
loc_i=this.att_tds.chercherLocalement(x_3.att_txt);
if (loc_i==null){
    this.att_tds.inserer(x_3.att_txt,  new VAR(x_3.att_txt, this.att_dep, true, x_2.att_type, "prive ", x_4.att_type));
}
else {
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_B_08, MJAVAMessages.B_08,new Object[]{""+x_3.att_txt});

}
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_code16_29(S_E_MJAVA x_2) throws Exception {
try {
// instructions
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_TRACE, MJAVAMessages.TRACE,new Object[]{""+"INST ---> E pv "+x_2.att_code});

this.att_code=x_2.att_code;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_taille_30(S_BLOC_MJAVA x_2) throws Exception {
try {
// instructions
this.att_taille=0;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_30(S_BLOC_MJAVA x_2) throws Exception {
try {
// instructions
x_2.att_tds=this.att_tds;
x_2.att_tdsi=this.att_tdsi;
x_2.att_dep=this.att_dep;
x_2.att_cpu=this.att_cpu;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_taille_34(S_E_MJAVA x_3) throws Exception {
try {
// instructions
this.att_taille=0;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_code15_28(S_TYPE_MJAVA x_2, T_MJAVA x_3, S_AFFX_MJAVA x_4) throws Exception {
try {
// instructions
if (x_4.att_code=="no"){
this.att_code=this.att_cpu.reserver_mem(x_2.att_type.getTaille());
}
else {
this.att_code=this.att_cpu.reserver_mem(x_2.att_type.getTaille())+x_4.att_code;
}
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_code17_30(S_BLOC_MJAVA x_2) throws Exception {
try {
// instructions
this.att_code=x_2.att_code;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_code18_31(S_E_MJAVA x_4, S_BLOC_MJAVA x_7, S_SIX_MJAVA x_8) throws Exception {
try {
// instructions
this.att_code=this.att_cpu.ifThenElse(x_4.att_code, x_7.att_code, x_8.att_code);
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_taille_29(S_E_MJAVA x_2) throws Exception {
try {
// instructions
this.att_taille=0;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_type_34(S_E_MJAVA x_3) throws Exception {
try {
// locales
TDS loc_tds;
// instructions
loc_tds=this.att_tds;
if (!(x_3.att_type.estBonTypeRetour(loc_tds))){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_T_09, MJAVAMessages.T_09,new Object[]{""+x_3.att_type.getNom()});

}

}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_28(S_TYPE_MJAVA x_2, T_MJAVA x_3, S_AFFX_MJAVA x_4) throws Exception {
try {
// instructions
x_2.att_tds=this.att_tds;
x_4.att_tds=this.att_tds;
x_2.att_tdsi=this.att_tdsi;
x_4.att_tdsi=this.att_tdsi;
x_4.att_cpu=this.att_cpu;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_auto_inh_35(S_E_MJAVA x_4, S_BLOC_MJAVA x_7) throws Exception {
try {
// instructions
x_4.att_tds=this.att_tds;
x_7.att_tds=this.att_tds;
x_4.att_tdsi=this.att_tdsi;
x_7.att_tdsi=this.att_tdsi;
x_7.att_dep=this.att_dep;
x_4.att_cpu=this.att_cpu;
x_7.att_cpu=this.att_cpu;
}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
private void action_type_28(S_TYPE_MJAVA x_2, T_MJAVA x_3, S_AFFX_MJAVA x_4) throws Exception {
try {
// instructions
if (!((x_4.att_type.heriteDe(x_2.att_type, this.att_tds)))){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMJAVAMessages.id_T_01, MJAVAMessages.T_01,new Object[]{""+x_2.att_type.getNom(), ""+x_4.att_type.getNom()});

}

}catch(RuntimeException e) {		//e.printStackTrace();
	}
  }
  public void analyser () throws Exception {
    scanner.lit ( 1 ) ;
    switch ( scanner.fenetre[0].code ) {
      case LEX_MJAVA.token_int : // 45460
        regle28 () ;
      break ;
      case LEX_MJAVA.token_bool : // 45461
        regle28 () ;
      break ;
      case LEX_MJAVA.token_ident : // 45490
        scanner.lit ( 2 ) ;
        switch ( scanner.fenetre[1].code ) {
          case LEX_MJAVA.token_ident : // 45490
            regle28 () ;
          break ;
          case LEX_MJAVA.token_pt : // 45454
            regle29 () ;
          break ;
          case LEX_MJAVA.token_paro : // 45446
            regle29 () ;
          break ;
          case LEX_MJAVA.token_mult : // 45480
            regle29 () ;
          break ;
          case LEX_MJAVA.token_div : // 45481
            regle29 () ;
          break ;
          case LEX_MJAVA.token_mod : // 45482
            regle29 () ;
          break ;
          case LEX_MJAVA.token_et : // 45483
            regle29 () ;
          break ;
          case LEX_MJAVA.token_plus : // 45477
            regle29 () ;
          break ;
          case LEX_MJAVA.token_moins : // 45478
            regle29 () ;
          break ;
          case LEX_MJAVA.token_ou : // 45479
            regle29 () ;
          break ;
          case LEX_MJAVA.token_inf : // 45471
            regle29 () ;
          break ;
          case LEX_MJAVA.token_infeg : // 45472
            regle29 () ;
          break ;
          case LEX_MJAVA.token_sup : // 45473
            regle29 () ;
          break ;
          case LEX_MJAVA.token_supeg : // 45474
            regle29 () ;
          break ;
          case LEX_MJAVA.token_eg : // 45475
            regle29 () ;
          break ;
          case LEX_MJAVA.token_neg : // 45476
            regle29 () ;
          break ;
          case LEX_MJAVA.token_affect : // 45455
            regle29 () ;
          break ;
          case LEX_MJAVA.token_pv : // 45453
            regle29 () ;
          break ;
          default :
                   scanner._interrompre(IProblem.Syntax, scanner.getBeginLine(), IMJAVAMessages.id_MJAVA_unexpected_token,MJAVAMessages.MJAVA_unexpected_token,new String[]{scanner.fenetre[1].getNom()});
scanner.accepter_sucre(LEX_MJAVA.token_ident);
        }
      break ;
      case LEX_MJAVA.token_entier : // 45489
        regle29 () ;
      break ;
      case LEX_MJAVA.token_vrai : // 45485
        regle29 () ;
      break ;
      case LEX_MJAVA.token_faux : // 45486
        regle29 () ;
      break ;
      case LEX_MJAVA.token_plus : // 45477
        regle29 () ;
      break ;
      case LEX_MJAVA.token_moins : // 45478
        regle29 () ;
      break ;
      case LEX_MJAVA.token_non : // 45484
        regle29 () ;
      break ;
      case LEX_MJAVA.token_nil : // 45470
        regle29 () ;
      break ;
      case LEX_MJAVA.token_paro : // 45446
        regle29 () ;
      break ;
      case LEX_MJAVA.token_nouveau : // 45465
        regle29 () ;
      break ;
      case LEX_MJAVA.token_this : // 45487
        regle29 () ;
      break ;
      case LEX_MJAVA.token_super : // 45488
        regle29 () ;
      break ;
      case LEX_MJAVA.token_aco : // 45448
        regle30 () ;
      break ;
      case LEX_MJAVA.token_si : // 45456
        regle31 () ;
      break ;
      case LEX_MJAVA.token_retour : // 45464
        regle34 () ;
      break ;
      case LEX_MJAVA.token_tantque : // 45458
        regle35 () ;
      break ;
      default :
               scanner._interrompre(IProblem.Syntax, scanner.getBeginLine(), IMJAVAMessages.id_MJAVA_unexpected_token,MJAVAMessages.MJAVA_unexpected_token,new String[]{scanner.fenetre[0].getNom()});
    }
  }
    private IDstNode parent;
    public void setParent( IDstNode p){parent = p;}
    public IDstNode getParent(){return parent;}
    private List<IDstNode> children = null ;
    public void addChild(IDstNode node){
      if (children == null) {
         children = new ArrayList<IDstNode>() ;}
      children.add(node);
      node.setParent(this);
    }
    public List<IDstNode> getChildren(){return children;}
    public boolean isLeaf(){return children == null;}
    public void accept(IDstVisitor visitor) {
      boolean visitChildren = visitor.visit(this);
      if (visitChildren && children != null){
        for(IDstNode node : children){
          node.accept(visitor);
        }
    }
    visitor.endVisit(this);
  }
  private int offset;
  private int length;
  public int getOffset(){return offset;}
  public void setOffset(int o){offset = o;}
  public int getLength(){return length;}
  public void setLength(int l){length = l;}
  private boolean malformed = false;
  public void setMalformed(){malformed = true;}
  public boolean isMalformed(){return malformed;}
  }
